import Vue from 'vue'
import VueRouter from "vue-router";
import Layout from '@/views/Layout'
import ArticleDetail from '@/views/ArticleDetail'
import Article from '@/views/Article'
import Collect from '@/views/Collect'
import Like from '@/views/Like'
import User from '@/views/User'

Vue.use(VueRouter)

const router = new VueRouter({
  routes: [
    // 重定向 访问/ 自动跳转到首页
    { path: '/', redirect: '/home/article' },
    {
      path: '/home',
      component: Layout,
      children: [
        // 注意点：
        // 1.配置二级路由时，path的值 不需要加 /
        // 2.配置完二级路由后，别忘了加一个路由出口 router-view(嵌套几级，就需要加几个路由出口)
        // 配置完二级路由之后，需要修改下重定向的路径
        // 首页底部的链接，也得对应的修改成二级路由
        { path: 'article', component: Article },
        { path: 'collect', component: Collect },
        { path: 'like', component: Like },
        { path: 'user', component: User }
      ]
    },
    { path: '/detail/:id', component: ArticleDetail },
  ]
})

export default router